/*
 * 
 */
package diagramaer.diagram.part;

import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.tooling.runtime.update.DiagramUpdater;

import diagramaer.ClaveAjena;
import diagramaer.Columna;
import diagramaer.DiagramaER;
import diagramaer.Tabla;
import diagramaer.diagram.edit.parts.ClaveAjenaEditPart;
import diagramaer.diagram.edit.parts.ColumnaEditPart;
import diagramaer.diagram.edit.parts.DiagramaEREditPart;
import diagramaer.diagram.edit.parts.TablaEditPart;
import diagramaer.diagram.edit.parts.TablaTablaClavesAjenasCompartmentEditPart;
import diagramaer.diagram.edit.parts.TablaTablaColumnasCompartmentEditPart;

/**
 * @generated
 */
public class DiagramaerDiagramUpdater {

	/**
	 * @generated
	 */
	public static boolean isShortcutOrphaned(View view) {
		return !view.isSetElement() || view.getElement() == null
				|| view.getElement().eIsProxy();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerNodeDescriptor> getSemanticChildren(View view) {
		switch (DiagramaerVisualIDRegistry.getVisualID(view)) {
		case DiagramaEREditPart.VISUAL_ID:
			return getDiagramaER_1000SemanticChildren(view);
		case TablaTablaColumnasCompartmentEditPart.VISUAL_ID:
			return getTablaTablaColumnasCompartment_7001SemanticChildren(view);
		case TablaTablaClavesAjenasCompartmentEditPart.VISUAL_ID:
			return getTablaTablaClavesAjenasCompartment_7002SemanticChildren(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerNodeDescriptor> getDiagramaER_1000SemanticChildren(
			View view) {
		if (!view.isSetElement()) {
			return Collections.emptyList();
		}
		DiagramaER modelElement = (DiagramaER) view.getElement();
		LinkedList<DiagramaerNodeDescriptor> result = new LinkedList<DiagramaerNodeDescriptor>();
		for (Iterator<?> it = modelElement.getTablas().iterator(); it.hasNext();) {
			Tabla childElement = (Tabla) it.next();
			int visualID = DiagramaerVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == TablaEditPart.VISUAL_ID) {
				result.add(new DiagramaerNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerNodeDescriptor> getTablaTablaColumnasCompartment_7001SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Tabla modelElement = (Tabla) containerView.getElement();
		LinkedList<DiagramaerNodeDescriptor> result = new LinkedList<DiagramaerNodeDescriptor>();
		for (Iterator<?> it = modelElement.getColumnas().iterator(); it
				.hasNext();) {
			Columna childElement = (Columna) it.next();
			int visualID = DiagramaerVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == ColumnaEditPart.VISUAL_ID) {
				result.add(new DiagramaerNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerNodeDescriptor> getTablaTablaClavesAjenasCompartment_7002SemanticChildren(
			View view) {
		if (false == view.eContainer() instanceof View) {
			return Collections.emptyList();
		}
		View containerView = (View) view.eContainer();
		if (!containerView.isSetElement()) {
			return Collections.emptyList();
		}
		Tabla modelElement = (Tabla) containerView.getElement();
		LinkedList<DiagramaerNodeDescriptor> result = new LinkedList<DiagramaerNodeDescriptor>();
		for (Iterator<?> it = modelElement.getClavesAjenas().iterator(); it
				.hasNext();) {
			ClaveAjena childElement = (ClaveAjena) it.next();
			int visualID = DiagramaerVisualIDRegistry.getNodeVisualID(view,
					childElement);
			if (visualID == ClaveAjenaEditPart.VISUAL_ID) {
				result.add(new DiagramaerNodeDescriptor(childElement, visualID));
				continue;
			}
		}
		return result;
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getContainedLinks(View view) {
		switch (DiagramaerVisualIDRegistry.getVisualID(view)) {
		case DiagramaEREditPart.VISUAL_ID:
			return getDiagramaER_1000ContainedLinks(view);
		case TablaEditPart.VISUAL_ID:
			return getTabla_2001ContainedLinks(view);
		case ColumnaEditPart.VISUAL_ID:
			return getColumna_3001ContainedLinks(view);
		case ClaveAjenaEditPart.VISUAL_ID:
			return getClaveAjena_3002ContainedLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getIncomingLinks(View view) {
		switch (DiagramaerVisualIDRegistry.getVisualID(view)) {
		case TablaEditPart.VISUAL_ID:
			return getTabla_2001IncomingLinks(view);
		case ColumnaEditPart.VISUAL_ID:
			return getColumna_3001IncomingLinks(view);
		case ClaveAjenaEditPart.VISUAL_ID:
			return getClaveAjena_3002IncomingLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getOutgoingLinks(View view) {
		switch (DiagramaerVisualIDRegistry.getVisualID(view)) {
		case TablaEditPart.VISUAL_ID:
			return getTabla_2001OutgoingLinks(view);
		case ColumnaEditPart.VISUAL_ID:
			return getColumna_3001OutgoingLinks(view);
		case ClaveAjenaEditPart.VISUAL_ID:
			return getClaveAjena_3002OutgoingLinks(view);
		}
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getDiagramaER_1000ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getTabla_2001ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getColumna_3001ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getClaveAjena_3002ContainedLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getTabla_2001IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getColumna_3001IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getClaveAjena_3002IncomingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getTabla_2001OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getColumna_3001OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static List<DiagramaerLinkDescriptor> getClaveAjena_3002OutgoingLinks(
			View view) {
		return Collections.emptyList();
	}

	/**
	 * @generated
	 */
	public static final DiagramUpdater TYPED_INSTANCE = new DiagramUpdater() {
		/**
		 * @generated
		 */
		@Override
		public List<DiagramaerNodeDescriptor> getSemanticChildren(View view) {
			return DiagramaerDiagramUpdater.getSemanticChildren(view);
		}

		/**
		 * @generated
		 */
		@Override
		public List<DiagramaerLinkDescriptor> getContainedLinks(View view) {
			return DiagramaerDiagramUpdater.getContainedLinks(view);
		}

		/**
		 * @generated
		 */
		@Override
		public List<DiagramaerLinkDescriptor> getIncomingLinks(View view) {
			return DiagramaerDiagramUpdater.getIncomingLinks(view);
		}

		/**
		 * @generated
		 */
		@Override
		public List<DiagramaerLinkDescriptor> getOutgoingLinks(View view) {
			return DiagramaerDiagramUpdater.getOutgoingLinks(view);
		}
	};

}
